import 'package:flutter/material.dart';

class ImageButton extends StatelessWidget {
  final double width;
  final double height;
  final bool active;
  final Widget? child;
  final GestureTapCallback? onTap;
  final ImageProvider background;
  final ImageProvider? activeBackground;
  final ImageProvider? disabledBackground;
  final EdgeInsetsGeometry? padding;

  const ImageButton({
    super.key,
    this.child,
    this.onTap,
    this.padding,
    this.active = false,
    required this.width,
    required this.height,
    required this.background,
    this.activeBackground,
    this.disabledBackground,
  });

  @override
  Widget build(BuildContext context) {
    return InkWell(
      onTap: onTap,
      child: Ink(
        width: width,
        height: height,
        padding: padding,
        decoration: BoxDecoration(
          image: DecorationImage(
              fit: BoxFit.fill,
              filterQuality: FilterQuality.high,
              image: onTap == null
                  ? disabledBackground ?? background
                  : active
                      ? activeBackground ?? background
                      : background),
        ),
        child: Align(child: child),
      ),
    );
  }
}
